package com.shen;

/**
 * Author:shen
 * CreateDate:2020/5/26.
 * Function:
 */
public class Credidate {
    static int num=0;//对象个数

    public Credidate() throws Exception {
        num++;
        if(num>3){
            throw new Exception("对象只能创建三个！");
        }
    }

    public static void main(String[] args) {
        try {
            Credidate credidate = new Credidate();
            Credidate credidate1 = new Credidate();
            Credidate credidate2 = new Credidate();
            Credidate credidate3 = new Credidate();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }


}
